package testUnitaires;

import static org.junit.Assert.*;
import gti310.tp4.*;

import java.util.ArrayList;

import jdk.nashorn.internal.ir.Block;

import org.junit.Before;
import org.junit.Test;

public class TestImageBlockMaker {
	
	ArrayList<ArrayList<double[][]>> componentList;
	ImageBlockMaker block1;
	ImageBlockMaker block2;
	ImageBlockMaker block3;
	ImageBlockMaker block4;
	double [][][] rgb1;
	double [][][] rgb2;
	double [][][] rgb3;
	double [][][] rgb4;
	int nbBloc1;
	int nbBloc2;
	int aireBlock;
	
	
	@Before
	public void aFaire(){
		rgb1 = new double [3][256][256];
		rgb2 = new double [3][254][257];
		rgb3 = new double [3][256][256];
		nbBloc1 = 256*256;
		nbBloc2 = 254*257;
		aireBlock = 8*8;
		
		block1 = new ImageBlockMaker(rgb1);
		block2 = new ImageBlockMaker(rgb2);
		
	}
	
	/**
	 * Test de la validation des dimensions
	 */
	@Test
	public void testValiderDimension(){
		assertTrue(block1.validerDimension(256, 256));
	}
	
	/**
	 * Test de la création des blocs
	 */
	@Test
	public void testDiviserBlock(){
		block1.diviserBlock();
		assertTrue(block1.getComponentList().size()==3 && 
				block1.getComponentList().get(0).size() == (nbBloc1/aireBlock));
	}
	
	/**
	 * Test d'erreurs
	 */
	@Test
	public void testValiderDimentionErreur(){
		assertFalse(block2.validerDimension(rgb2[0].length, rgb2[0][0].length));
	}
	
	@Test
	public void testDiviserBlockErreur(){
		block2.diviserBlock();
		assertFalse(block2.getComponentList().size()==3 && 
				block2.getComponentList().get(0).size() == (nbBloc2/aireBlock));
	}

}
